package com.zhida.jiyangcenter.coupon

import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import chooongg.base.annotation.ContentLayout
import chooongg.base.widget.recyclerView.divider.HorizontalDividerItemDecoration
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.zhida.jiyangcenter.R
import com.zhida.jiyangcenter.mian.BaseFragment
import kotlinx.android.synthetic.main.list.*

@ContentLayout(R.layout.list)
class CouponHistoryFragment(type:Int):BaseFragment() {
    val adapter=Adapter(type)
    override fun initConfig(savedInstanceState: Bundle?) {
        recycler_view.layoutManager=LinearLayoutManager(context)
        recycler_view.addItemDecoration(HorizontalDividerItemDecoration.Builder(requireContext()).sizeResId(R.dimen.dividerBig).colorResId(R.color.colorBack).build())

        recycler_view.adapter=adapter
        adapter.setNewData(ArrayList<String>().apply {
            add("akjsh")
            add("akjsh")
            add("akjsh")
            add("akjsh")
            add("akjsh")
            add("akjsh")
            add("akjsh")
            add("akjsh")
        })
    }
    class Adapter(val type:Int):BaseQuickAdapter<String,BaseViewHolder>(R.layout.item_coupon_history){
        override fun convert(helper: BaseViewHolder, item: String?) {
            if (type==1){
                helper.setImageResource(R.id.iv_backgraoud,R.drawable.iv_backgroud_coupon_use).setImageResource(R.id.iv_coupon_type,R.drawable.iv_coupon_use)
            }else{
                helper.setImageResource(R.id.iv_backgraoud,R.drawable.iv_backgroud_coupon_guoqi).setImageResource(R.id.iv_coupon_type,R.drawable.iv_coupon_guoqi)

            }
        }

    }

}